﻿<cfcomponent>
<cfscript>
DB = 'chinalaohu';
dbt = 'auction_userwonpaid';
domain = 'http://img1.chinalaohu.com';
</cfscript>
<cfparam name="UUID" default="0" type="string" >

<cffunction name="auction" access="remote" returnFormat="json">
  <cfscript>
	j = {"success":"0"};
	</cfscript>
	<!---根据UUID查找ID--->
  <cfinvoke component="app.cfc.user" method="uuidgetuid" returnvariable="uuidgetuid" UUID="#uuid#"/>
  <cfif uuidgetuid.recordcount neq 1>
  	<!---,"msg":"用户ID错误"--->
    <cfset j = {"success":"0","errCode":"0"}>
  <cfelse>
  	<cfif isdefined('id') and isnumeric(id)>
    	<cfinvoke component="app.cfc.userwon" method="chacktopaid" returnvariable="chacktopaid" aid="#id#" />
      <cfif chacktopaid.recordcount eq 0>
				<cfscript>
				//,"msg":"拍品未加入交易单"
        j = {"success":"0","errCode":"-1"};
        </cfscript>
      <cfelse>
      	<!---暂时取消查看权限--->
      	<!---<cfif chacktopaid.uid neq uuidgetuid.uid>
					<cfscript>
          j = {"success":"0","msg":"无权查看"};
          </cfscript>
        <cfelse>--->
        	<cfinvoke component="app.cfc.userwon" method="logistic" returnvariable="logistic" aid="#id#" />
          <cfquery datasource="#DB#" name="ag">
          SELECT
          auction.agid,
          auction_gallery.img_waterfall
          FROM
          auction
          INNER JOIN auction_gallery ON auction_gallery.agid = auction.agid
          WHERE
          auction.aid = #id#
          </cfquery>
          <cfscript>
					imgUrl = '';
					if (ag.recordcount gt 0){
						imgUrl = domain & replacenocase(ag.img_waterfall,'/upload/','/upload/ios/');
					}

					//模拟物流跟踪
					/*
					tracking = [{"time":"2012-07-07 13:35:14","context":"客户已签收"},
 {"time":"2012-07-07 09:10:10","context":"离开 [北京石景山营业厅] 派送中，递送员[温]，电话[]"},
 {"time":"2012-07-06 19:46:38","context":"到达 [北京石景山营业厅]"},
 {"time":"2012-07-06 15:22:32","context":"离开 [北京石景山营业厅] 派送中，递送员[温]，电话[]"},
 {"time":"2012-07-06 15:05:00","context":"到达 [北京石景山营业厅]"},
 {"time":"2012-07-06 13:37:52","context":"离开 [北京_同城中转站] 发往 [北京石景山营业厅]"},
 {"time":"2012-07-06 12:54:41","context":"到达 [北京_同城中转站]"},
 {"time":"2012-07-06 11:11:03","context":"离开 [北京运转中心驻站班组] 发往 [北京_同城中转站]"},
 {"time":"2012-07-06 10:43:21","context":"到达 [北京运转中心驻站班组]"},
 {"time":"2012-07-05 21:18:53","context":"离开 [福建_厦门支公司] 发往 [北京运转中心_航空]"},
 {"time":"2012-07-05 20:07:27","context":"已取件，到达 [福建_厦门支公司]"}
];					*/
					
					
					
					logistics = {
						"company":logistic.shipment,                                           //快递公司
						"orderNumber":logistic.ship_no,                                     //物流单号
						"insuredPrice":Numberformat(logistic.bid_amount,'_.__'),                                         //保价金额
						"insuredPay":Numberformat(logistic.insure_fee,'_.__'),                                             //保价费用          
						"name":logistic.auction,                                           //拍品名称
						"id":logistic.acode,                                                 //拍品编号
						"imgUrl":imgUrl,                  //拍品图片 
						"dealTime":datetimeformat(logistic.endtime,'yyyy-mm-dd HH:NN:SS'),
						"price":Numberformat(logistic.bid_amount,'_.__'),
						"tracking":   []                                         //拍品价格
					};
					
					j = {"success":"1","logistics":logistics};
					</cfscript>

        <!---</cfif>--->
      
      </cfif>    
    <cfelse>
			<cfscript>
			//,"msg":"缺少参数"
      j = {"success":"0","errCode":"-1"};
      </cfscript>
    </cfif>
  </cfif>

  
  <cfscript>
	j = createObject("component",'cfjson').encode(j);
  return j;
	</cfscript>

</cffunction>



</cfcomponent>